package cqut.wys.controller;

import cqut.wys.util.Helper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * --------神兽出没--------/
 *   ┌─┐     ┌─┐
 * ┌─┘─┴─────┘─┴─┐
 * │      ─      │
 * │  ┬─┘   └─┬  │
 * │             │
 * │      ┴      │  Code is far away from bug with the animal protecting
 * └───┐      ┌──┘  神兽保佑,代码无bug
 *     │      │
 *     │      └──────┐
 *     │             ├┐
 *     │             ┌┘
 *     └┐ ┐ ┌───┬─┐ ┌┘
 *      │ ┤ ┤   │ ┤ ┤
 *      └─┴─┘   └─┴─┘
 * ----------------------/
 *
 * @author wys
 * @date 2020/2/25
 */
@RestController
public class IndexController {

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private Helper helper;

    @Value("${aa}")
    private String aa;

    @GetMapping("/")
    public String index(){
        System.out.println(aa);
        return aa;
    }

    @GetMapping("/update")
    public String update(){
        helper.processField(applicationContext.getBean("indexController"),
                "aa","bb");
        return "cc";
    }

}
